package com.bestvike.stone.spring.rabbit.core;

import org.springframework.amqp.rabbit.listener.adapter.DelegatingInvocableHandler;
import org.springframework.amqp.rabbit.listener.adapter.HandlerAdapter;
import org.springframework.messaging.Message;
import org.springframework.messaging.handler.invocation.InvocableHandlerMethod;

/**
 * Created by 许崇雷 on 2017-11-30.
 */
public final class RabbitHandlerAdapter extends HandlerAdapter implements IHandlerAdapter {
    public RabbitHandlerAdapter(InvocableHandlerMethod invokerHandlerMethod) {
        super(invokerHandlerMethod);
    }

    public RabbitHandlerAdapter(DelegatingInvocableHandler delegatingHandler) {
        super(delegatingHandler);
    }

    @Override
    public Object invoke(Message<?> message, Object... providedArgs) {
        return this.invokeCore(this.getMethodAsString(message.getPayload()), message, providedArgs);
    }

    @Override
    public Object invokeSuper(Message<?> message, Object... providedArgs) throws Exception {
        return super.invoke(message, providedArgs);
    }
}
